package com.jiaying.patient.view;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DoctorMainView extends JFrame {

    /**桌面面板  可以继续往上面放子面板 */
    private JDesktopPane panel_desktop;
    /** 按钮组面板 有很多按钮 */
    private JPanel panel_buttons;
    /** 主面板  */
    private JPanel panel_main;

    /** 图片标签 */
    private JLabel lb_img;
    /** 患者信息查询按钮 */
    private JButton btn_query_patient;
    /** 患者病例详情查询按钮 */
    private JButton btn_query_record_detail;
    /** 退出按钮 */
    private JButton btn_exit;

    private void init(){
        //初始化
      //  this.lb_img=new JLabel(new ImageIcon(ClassLoader.getSystemResource("images/fengjing.jpg")));
        this.lb_img=new JLabel(new ImageIcon(ClassLoader.getSystemResource("images/c.jpg")));
        this.lb_img.setBounds(0, 0, 800, 500);


        btn_exit=new JButton("退出窗口");
        this.btn_query_patient=new JButton("患者信息查询");

        //给 患者信息查询 按钮注册侦听器
        btn_query_patient.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("你点击了患者信息查询按钮。。。。。。。。。");
                // 真实目的：开一个子窗体放入DesktopPanel
                DoctorQueryPatientView doctorQueryPatientView=new DoctorQueryPatientView();
                panel_desktop.add(doctorQueryPatientView);
                doctorQueryPatientView.toFront();
            }
        });


        this.btn_query_record_detail=new JButton("患者病例详情查询");

        this.panel_buttons=new JPanel(new GridLayout(7,1,0,30));//网格布局
        //为按钮组面板创建包含主题的边框，同时边框具有浮雕效果
        //为了创建指定的边框效果，那么先创建标题边框，可以设置标题，然后这个方法中的第一个参数可以另外一种边框样式，我们这里是浮雕样式，面板有突起效果
        panel_buttons.setBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(),"快捷功能区"));
        this.panel_desktop=new JDesktopPane();
        this.panel_main=new JPanel(new BorderLayout());//方位布局


        //拼装
        this.panel_desktop.add(lb_img);
        this.panel_buttons.add(btn_query_patient);
        this.panel_buttons.add(new JLabel());
        this.panel_buttons.add(new JLabel());
        this.panel_buttons.add(btn_query_record_detail);
        this.panel_buttons.add(new JLabel());
        this.panel_buttons.add(new JLabel());
        this.panel_buttons.add(btn_exit);

        this.panel_main.add(panel_desktop,BorderLayout.CENTER);
        this.panel_main.add(panel_buttons,BorderLayout.EAST);

        this.getContentPane().add(panel_main);



    }

    public DoctorMainView(){
        init();  //必须

        this.setTitle("医生主窗体"); //标题

        this.setSize(1000,600);

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//程序退出操作

        this.setResizable(false);  //不能缩放

        this.setLocationRelativeTo(null); //居中

        this.setVisible(true);//显示
    }
}
